package cn.jingzhuan.fm.ui.decoration;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

public class HorizontalSpacesItemDecoration extends RecyclerView.ItemDecoration {
  private int space;

  public HorizontalSpacesItemDecoration(int space) {
    this.space = space;
  }

  @Override
  public void getItemOffsets(Rect outRect, View view,
                             RecyclerView parent, RecyclerView.State state) {
    //outRect.left = space;
    //outRect.right = space;
    //outRect.bottom = space;

    // Add top margin only for the first item to avoid double space between items
    if (parent.getChildLayoutPosition(view) == 0) {
        outRect.left = 0;
    } else {
        outRect.left = space;
    }
  }
}